#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
#include<string>
#include<cstdlib>
class Solution
{
    friend void stackpush(Solution* st, char x);
    friend void outstack(Solution* st);

public:
    bool isValid(Solution*st,string s)
    {
        int i = 0;
        while (s[i])
        {
            if ((s[i] == '[') || (s[i] == '{') || (s[i] == '('))
            {
                stackpush(st, s[i]);
                i++;
            }
            else
            {
                if (st->top<0)
                {
                    return false;
                }
                char ret = st->point[st->top - 1];
                if((s[i]==']'&&ret=='[')||(s[i]=='}'&&ret=='{')||(s[i]==')'&&ret=='('))
                {
                    i++;
                    outstack(st);
                }
                else
                {
                    return false;
                }
            }
        }
        if (st->top != 0)
        {
            return false;
        }
        return true;
    }
    Solution(){
        top = 0;
        point = NULL;
        capacity = 0;
    }
    ~Solution() {
        delete[]point;
        point = NULL;
    }
    int top;
    char* point;
    int capacity;
};
void stackpush(Solution* st, char x)
{
    char* pointer;
    if (st->top == st->capacity)
    {
        int newcapacity = st->capacity * 2;
        if (st->capacity == 0)
        {
            newcapacity = 4;
        }
        pointer = (char*)realloc(st->point, sizeof(int) * newcapacity);
        st->point = pointer;
        st->capacity = newcapacity;
    }
    if (st->top < 0)
    {
        st->top++;
    }
    st->point[st->top] = x;
    st->top++;
}
void outstack(Solution* st)
{
    st->top--;
}
void text()
{
    string str;
    Solution p;
    while (1)
    {
        getline(cin, str);
        if (str == "quit")
        {
            break;
         }
        bool ret=p.isValid(&p,str);
        if (ret)
        {
            cout << "yes" << endl;
            p.top = 0;
            p.capacity = 0;
            delete p.point;
            p.point = NULL;
        }
        else
        {
            cout << "no" << endl;
            p.top = 0;
            p.capacity = 0;
            delete p.point;
            p.point = NULL;
        }
    }
}
int main()
{
    text();

	system("pause");
}